<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.w3.org/1999/xhtml">
<head>
    <meta charset="UTF-8">
    <title>成绩</title>
    <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/semantic-ui@2.4.2/dist/semantic.min.css">
    <script src="https://cdn.jsdelivr.net/npm/jquery@3.2/dist/jquery.min.js"></script>
    <script src="https://cdn.jsdelivr.net/npm/semantic-ui@2.4.2/dist/semantic.min.js"></script>
</head>
<body>

<nav th:replace="teacher/_fragments :: menu(5)" class="ui inverted  segment">
    <div class="ui container">
        <div class="ui inverted secondary menu">
            <h2 class="ui teal header item">CUMT</h2>
            <h3 class="ui teal header item">在线答题系统</h3>
            <a href="#" class="  item ">章节</a>
            <a href="#" class=" item ">知识点</a>
            <a href="#" class=" item ">题目</a>
            <a href="#" class=" item ">试卷</a>
            <a href="#" class="active item ">成绩</a>

            <div class="right menu   ">
                <div class="ui dropdown item">
                    <div class="text">
                        Zhaohaihang
                    </div>
                    <i class="dropdown icon"></i>
                    <div class="menu">
                        <a href="#" class="item">注销</a>
                    </div>
                </div>
            </div>
        </div>
    </div>
</nav>

<div class="ui  container">
    <div  class="ui secondary segment form">
        <input type="hidden" name="page">
        <div class="four fields">
            <div class=" required field">
                <div class=" required field">
                    <div class="ui left labeled input">
                        <label class="ui teal basic label"> 姓名</label>
                        <input type="text" name="stuname" placeholder="XXXXXX" class="input-box">
                    </div>
                </div>
            </div>

            <div class=" required field">
                <div class=" required field">
                    <div class="ui left labeled input">
                        <label class="ui teal basic label"> 学号</label>
                        <input type="text" name="stunum" placeholder="XXXXXX" class="input-box">
                    </div>
                </div>
            </div>

            <div class=" required field">
                <div class=" required field">
                    <div class="ui left labeled input">
                        <label class="ui teal basic label"> 年级</label>
                        <input type="text" name="stugrade" placeholder="XXXXXX" class="input-box">
                    </div>
                </div>
            </div>

            <div class=" required field">
                <div class=" required field">
                    <div class="ui left labeled input">
                        <label class="ui teal basic label"> 试卷名</label>
                        <input type="text" name="papername" placeholder="XXXXXX" class="input-box">
                    </div>
                </div>
            </div>

            <div class="field">
                <button  id ="clear-btn" class="ui  button">清空</button>
                <button type="button" id="search-btn" class="ui  orange basic button"><i class="search icon"></i>搜索</button>
            </div>
        </div>
    </div>

    <div id="table-container"  class="">
    <table th:fragment="gradeList" class="ui celled compact teal table">
        <thead>
        <tr>
            <th >序号</th>
            <th>ID</th>
            <th>姓名</th>
            <th>学号</th>
            <th>年级</th>
            <th>试卷名</th>
            <th>分数</th>
            <th>操作</th>
        </tr>
        </thead>
        <tbody>
        <tr th:each="stupap,iterStat : ${page.content}">
            <td th:text="${iterStat.count}">1</td>
            <td th:text="${stupap.student.id}">156</td>
            <td th:text="${stupap.student.name}">赵海航</td>
            <td th:text="${stupap.student.studentNum}">22150427</td>
            <td th:text="${stupap.student.grade}">2019级</td>
            <td th:text="${stupap.paper.name}">第一章练习题</td>
            <td ><span th:text="${stupap.score}"></span>/<span th:text="${stupap.paper.totalScore}"></span></td>
            <td>
                <a  th:href="@{/teacher/{studentid}/{paperid}/tea-grade-see(studentid=${stupap.student.id},paperid=${stupap.paper.id})}" class="ui seeButton mini basic teal button"  >查看</a>
            </td>
        </tr>

        </tbody>
        <tfoot>
        <tr>
            <th colspan="10">
                <div class="ui  mini  pagination menu" th:if="${page.totalPages}>1">
                    <a  onclick="page(this)" th:attr="data-page=${page.number}-1" class=" item" th:unless="${page.first}">上一页</a>
                    <a  onclick="page(this)" th:attr="data-page=${page.number}+1" class=" item" th:unless="${page.last}">下一页</a>
                </div>
            </th>
        </tr>

        </tfoot>
    </table>
    </div>
</div>


<script>
    $('.ui.dropdown').dropdown({
        on: 'hover'
    });

    $('#clear-btn')
        .on('click', function() {
            $('.input-box')
                .val('')
            ;
        });

    $("#search-btn").click(function () {
        $("[name='page']").val(0);
        loaddata();
    });
    function loaddata() {
        $("#table-container").load(/*[[@{/teacher/tea-grade/search}]]*/"/teacher/tea-grade/search",{
            stuname : $("[name='stuname']").val(),
            stunum : $("[name='stunum']").val(),
            stugrade : $("[name='stugrade']").val(),
            papername : $("[name='papername']").val(),
            page : $("[name='page']").val()
        });
    };

    function page(obj) {
        $("[name='page']").val($(obj).data("page"));
        loaddata();
    };
</script>

</body>
</html>